﻿using HengWang.OA.Bll;
using HengWang.OA.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace HengWang.OA.Web.Controllers
{
    public class AdminController : Controller
    {
        //
        // GET: /Admin/
        [HttpGet]
        public ActionResult Login()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Login(string uid, string pwd)
        {
            StaffInfoBll sb = new StaffInfoBll();
           var model= sb.Single(u =>u.Name == uid && u.Password == pwd);
            if (model==null)
            {
                return Redirect("/Admin/Error");
            }
            else
            {
                Session["admin"] = model;
                return Redirect("/Home/index");
            }
            
        }
        public ActionResult Error() {
            return View();
        }

        //极验滑动验证码
        public ActionResult GeekTest()
        {
            return Content(GetCaptcha(), "application/json");
        }
        private string GetCaptcha()
        {
            var geetest = new GeetestLib("7f8cfbad6525535e637bcb59a20550f8", "ae62d001e558b9dfca3e4c4f40032fcd");
            var gtServerStatus = geetest.preProcess();
            Session[GeetestLib.gtServerStatusSessionKey] = gtServerStatus;
            return geetest.getResponseStr();
        }

    }
}
